﻿using System;
using System.Data;
using System.Collections.Generic;
using He.Model;
namespace He.BLL
{
	/// <summary>
	/// logistics
	/// </summary>
	public partial class logistics
	{
		private readonly He.DAL.logistics dal=new He.DAL.logistics();
		public logistics()
		{}
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int id)
		{
			return dal.Exists(id);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(He.Model.logistics model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(He.Model.logistics model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int id)
		{
			
			return dal.Delete(id);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string idlist )
		{
			return dal.DeleteList(idlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public He.Model.logistics GetModel(int id)
		{
			
			return dal.GetModel(id);
		}


		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<He.Model.logistics> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<He.Model.logistics> DataTableToList(DataTable dt)
		{
			List<He.Model.logistics> modelList = new List<He.Model.logistics>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				He.Model.logistics model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new He.Model.logistics();
					if(dt.Rows[n]["id"]!=null && dt.Rows[n]["id"].ToString()!="")
					{
						model.id=int.Parse(dt.Rows[n]["id"].ToString());
					}
					if(dt.Rows[n]["order_number"]!=null && dt.Rows[n]["order_number"].ToString()!="")
					{
					model.order_number=dt.Rows[n]["order_number"].ToString();
					}
					if(dt.Rows[n]["status"]!=null && dt.Rows[n]["status"].ToString()!="")
					{
						model.status=int.Parse(dt.Rows[n]["status"].ToString());
					}
					if(dt.Rows[n]["sender_name"]!=null && dt.Rows[n]["sender_name"].ToString()!="")
					{
					model.sender_name=dt.Rows[n]["sender_name"].ToString();
					}
					if(dt.Rows[n]["sender_tel"]!=null && dt.Rows[n]["sender_tel"].ToString()!="")
					{
					model.sender_tel=dt.Rows[n]["sender_tel"].ToString();
					}
					if(dt.Rows[n]["sender_phone"]!=null && dt.Rows[n]["sender_phone"].ToString()!="")
					{
					model.sender_phone=dt.Rows[n]["sender_phone"].ToString();
					}
					if(dt.Rows[n]["sender_zipcode"]!=null && dt.Rows[n]["sender_zipcode"].ToString()!="")
					{
					model.sender_zipcode=dt.Rows[n]["sender_zipcode"].ToString();
					}
					if(dt.Rows[n]["sender_address"]!=null && dt.Rows[n]["sender_address"].ToString()!="")
					{
					model.sender_address=dt.Rows[n]["sender_address"].ToString();
					}
					if(dt.Rows[n]["receiver_name"]!=null && dt.Rows[n]["receiver_name"].ToString()!="")
					{
					model.receiver_name=dt.Rows[n]["receiver_name"].ToString();
					}
					if(dt.Rows[n]["receiver_tel"]!=null && dt.Rows[n]["receiver_tel"].ToString()!="")
					{
					model.receiver_tel=dt.Rows[n]["receiver_tel"].ToString();
					}
					if(dt.Rows[n]["receiver_phone"]!=null && dt.Rows[n]["receiver_phone"].ToString()!="")
					{
					model.receiver_phone=dt.Rows[n]["receiver_phone"].ToString();
					}
					if(dt.Rows[n]["receiver_zipcode"]!=null && dt.Rows[n]["receiver_zipcode"].ToString()!="")
					{
					model.receiver_zipcode=dt.Rows[n]["receiver_zipcode"].ToString();
					}
					if(dt.Rows[n]["receiver_address"]!=null && dt.Rows[n]["receiver_address"].ToString()!="")
					{
					model.receiver_address=dt.Rows[n]["receiver_address"].ToString();
					}
					if(dt.Rows[n]["create_time"]!=null && dt.Rows[n]["create_time"].ToString()!="")
					{
					model.create_time=dt.Rows[n]["create_time"].ToString();
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			return dal.GetRecordCount(strWhere);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			return dal.GetListByPage( strWhere,  orderby,  startIndex,  endIndex);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

